from flask import Flask
from flask import request
from flask import render_template
from Mysql import Mysql
from Service import query_database

app =Flask(__name__)

@app.route('/', methods=['GET'])
def home():
    db = Mysql()
    keywords = '泽'
    results = query_database(keywords)
    return render_template('home.html', results=results)

@app.route('/query', methods=['GET', 'POST'])
def query():

    keywords = '泽'
    if request.method == "POST":
        keywords = request.form['name']
    else:
        keywords = '泽'
    results = query_database(keywords)
    return render_template('home.html', results=results)


if __name__ == '__main__':
    app.run()